package is.ru.honn.rumblr.data;

import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Karl J. Karlsson
 * @version 0.9, 6. Oct 2011
 */
public class PostDetailMapper implements ParameterizedRowMapper<PostDetail>
{
    //Fills into a postDetail from the results(from table) and returns the postDetail
    public PostDetail mapRow(ResultSet rs, int rowNum) throws SQLException
    {

        PostDetail postDetail = null;

        try
        {
            postDetail = new PostDetail();
            postDetail.setPostid(rs.getString(1));
            postDetail.setName(rs.getString(2));
            postDetail.setValue(rs.getString(3));
        }
        catch (Exception ex)
        {
            String msg = "Unable to create PostDetails from ResultSet";
            throw new SQLException(msg);
        }
        return postDetail;
    }
}
